package com.ruoyi.logistic.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.logistic.domain.NetworkSheetFeeFillCollectCollect;
import com.ruoyi.logistic.domain.NetworkSheetFeeFillCollectDetail;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.vo.NetworkSheetFeeFillCollectCollectVo;
import com.ruoyi.logistic.domain.vo.NetworkSheetFeeFillCollectDetailVo;
import com.ruoyi.logistic.mapper.NetworkSheetFeeFillCollectCollectMapper;
import com.ruoyi.logistic.mapper.NetworkSheetFeeFillCollectDetailMapper;
import com.ruoyi.logistic.service.NetworkSheetFeeFillCollectDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class NetworkSheetFeeFillCollectDetailServiceImpl implements NetworkSheetFeeFillCollectDetailService {
    @Autowired
    private NetworkSheetFeeFillCollectDetailMapper networkSheetFeeFillCollectDetailMapper;
    @Autowired
    private NetworkSheetFeeFillCollectCollectMapper networkSheetFeeFillCollectCollectMapper;
    @Override
    public List<NetworkSheetFeeFillCollectDetail> selectAll(PageDate pageDate) {
        PageHelper.startPage(pageDate);
        return networkSheetFeeFillCollectDetailMapper.selectAll();
    }

    @Override
    public Boolean insert(NetworkSheetFeeFillCollectDetail networkSheetFeeFillCollectDetail) {
        return networkSheetFeeFillCollectDetailMapper.insert(networkSheetFeeFillCollectDetail);
    }

    @Override
    public Boolean update(NetworkSheetFeeFillCollectDetail networkSheetFeeFillCollectDetail) {
        return networkSheetFeeFillCollectDetailMapper.update(networkSheetFeeFillCollectDetail);
    }

    @Override
    public Boolean deleteById(Integer id) {
        return networkSheetFeeFillCollectDetailMapper.deleteById(id);
    }

    @Override
    public NetworkSheetFeeFillCollectDetail findById(Integer id) {
        return networkSheetFeeFillCollectDetailMapper.findById(id);
    }

    @Override
    public List<NetworkSheetFeeFillCollectDetail> search(NetworkSheetFeeFillCollectDetailVo networkSheetFeeFillCollectDetailVo) {
        PageHelper.startPage(networkSheetFeeFillCollectDetailVo.getPageDate());
        return networkSheetFeeFillCollectDetailMapper.search(networkSheetFeeFillCollectDetailVo);
    }

    @Override
    public List<NetworkSheetFeeFillCollectCollect> collect(NetworkSheetFeeFillCollectCollectVo networkSheetFeeFillCollectCollectVo) {
        PageHelper.startPage(networkSheetFeeFillCollectCollectVo.getPageDate());
        List<NetworkSheetFeeFillCollectCollect> collectCollectList = networkSheetFeeFillCollectCollectMapper.collect(networkSheetFeeFillCollectCollectVo);
        if (collectCollectList != null || collectCollectList.size() != 0){
            for (NetworkSheetFeeFillCollectCollect networkSheetFeeFillCollectCollect : collectCollectList){
                if (networkSheetFeeFillCollectCollectVo.getCollectDimensionality() == 1){
                    networkSheetFeeFillCollectCollect.setCollectTime(networkSheetFeeFillCollectCollectVo.getStartTime() + "至" + networkSheetFeeFillCollectCollectVo.getEndTime());
                }else {
                    networkSheetFeeFillCollectCollect.setCollectTime(networkSheetFeeFillCollectCollectVo.getStartMonth() + "至" + networkSheetFeeFillCollectCollectVo.getEndMonth());
                }
            }
        }
        return collectCollectList;
    }



}
